#include<iostream>
using namespace std;

/**
 * 类中静态成员变量，在类中声明，在类外定义
*/
class Person{
public:
    static int sNum;
private:
    static int sOther;
};


int Person::sNum = 20;
int Person::sOther = 300;

int main(int argc, char *argv[])
{
    /*通过类名引用*/
    Person::sNum = 200;
    cout << "sNum = " << Person::sNum << endl;

    /*通过对象访问*/
    Person p1, p2;
    p1.sNum = 300;

    cout << "p1.sNum = " << p1.sNum << endl;
    cout << "p2.sNum = " << p2.sNum << endl;

    /*静态成员变量的访问权限依然需要遵守*/
    Person p3;
    // p3.sOther = 300;
}